
package com.catsic.zcjc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.catsic.base.BaseServiceImpl;
import com.catsic.base.exception.CatsicException;
import com.catsic.core.exception.CatsicExceptionCode;
import com.catsic.zcjc.constants.ZcjcConstants;
import com.catsic.zcjc.dao.MaintainDataFileDao;
import com.catsic.zcjc.entity.MaintainDataFile;
import com.catsic.zcjc.service.MaintainDataFileService;


@Service("maintainDataFileService")
public class MaintainDataFileServiceImpl extends BaseServiceImpl<MaintainDataFile, String> implements MaintainDataFileService {
	
	/**
	 * maintainDataFileDao:设备Dao
	 */
	@Autowired
	private MaintainDataFileDao maintainDataFileDao;
	

	@Override
	public MaintainDataFile add(MaintainDataFile data) {
		super.add(data);
		return data;
	}


	@Override
	public MaintainDataFile findById(String id){
		MaintainDataFile data = getById(id);
		if(null == data){
			throw new CatsicException(CatsicExceptionCode.实体不存在, ZcjcConstants.EQUIP_MAINTAIN);
		}
		return data;
	}


	@Override
	public MaintainDataFile findByMaintainId(String id){
		List<MaintainDataFile> files = maintainDataFileDao.findByMaintainId(id);
		MaintainDataFile data = null;
		if(!files.isEmpty()){
			data = files.get(0);
		}
		return data;
	}



}
